package io.reader;

import framework.AbstractTest;
import utils.IOUtils;
import utils.Log;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;

/**
 * Created by shane on 2018/5/20.
 */
public class FormattedMemoryInput2 extends AbstractTest {
    protected static final String TAG = FormattedMemoryInput2.class.getName();

    @Override
    public void test(String[] args) {
        super.test(args);

        String testFilePath = getDefInputFile(args);
        DataInputStream in = null;
        try {
            in = new DataInputStream(
                    new ByteArrayInputStream(BufferedInputFile.read(testFilePath).getBytes()));
            while (in.available() > 0) {
                // 通过抛出 EOFException 来终止循环
                char c = (char)in.readByte();
                Log.v(c);
            }
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
            IOUtils.close(in);
        }
    }

    @Override
    protected String getTag() {
        return TAG;
    }
}
